package top.haichi.webpaper.controller;

import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Insert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.haichi.webpaper.entity.Result;
import top.haichi.webpaper.entity.Student;
import top.haichi.webpaper.entity.User;
import top.haichi.webpaper.mapper.StudentMapper;
import top.haichi.webpaper.mapper.UserMapper;
import top.haichi.webpaper.service.StudentService;
import top.haichi.webpaper.service.UserLoginService;
import top.haichi.webpaper.utils.JwtUtils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

@Slf4j
@RestController

//登录和注册控制器
public class UserController {
    @Autowired
    private UserLoginService userLoginService;


    /**
     * 登录接口
     * @param user
     * @return
     */
    @PostMapping("/user/login")
    public Result login(@RequestBody User user){
            return userLoginService.login(user);
    }

    /**
     * 注册接口
     * @param user
     * @return
     */
    @PostMapping("/user/register")
    public Result register(@RequestBody User user){
        return userLoginService.register(user);
    }


}
